module;
#include <napi.h>
#include <Windows.h>
module exports;

namespace yichu {
	using Napi::Value;
	using Napi::CallbackInfo;
	using Napi::Env;
	using Napi::Number;

	Value setAlpha(const Napi::CallbackInfo& info)
	{
		Env env = info.Env();
		if (info.Length() < 2)
		{
			Napi::TypeError::New(env, "Number of arg wrong").ThrowAsJavaScriptException();
			return env.Undefined();
		}
		HWND hwnd = HWND(info[0].As<Number>().Int32Value());
		BYTE alpha = BYTE(info[1].As<Number>().Int32Value());
		Window* w = new Window(hwnd);
		w->setAlpha(alpha);
		delete w;
		return env.Undefined();
	}

	Value getWindow(const Napi::CallbackInfo& info)
	{
		Env env = info.Env();
		HWND hwnd = Window::getHwndByCursor();
		return Number::New(env,int(hwnd));
	}
}